home *** CD-ROM | disk | FTP | other *** search
-
- Programming Example
-
- The sources avg.c and avg2.a are programming examples on how to setup
- and call
-
- -- assembler routines from C
- -- AmigaDos routines from C
- -- library routines from assembler routines
- -- AmigaDos routines from assembler routines.
-
- In addition there is an example of how to create an assembler routine that
- can be called with parameters passed on the stack as well as in register.
- This feature allows you to have one routine that can be used whether you
- compile with 'parms=stack' or 'parms=register'. Also, you can create
- C language routines with this same dual nature by using the 'parms=both'
- option. This is infact how we build our link libraries.
-
- To build the program compile and link the sources with the build line
- (sc avg.c avg2.a incdir=include: link) to produce an executable named 'avg'.
- This program will accept numeric command line arguments and return for you
- the average of the numeric values. To do this it uses two assembler
- routines (avg() and prnts()) to compute and print the average. avg() is
- the routine that is built to handle both stack and register parameters.
- prnts() is calls the AmigaDos Write() routine to write to the console.
- If no arguments are given, the program returns a usage message.
-
- Ex: 1> avg 1 2 3
- average = 2
-
- As with all our examples, feel free to experiment with different compilation
- options and startups. In the sources themselves are some hints as to the
- different things that you can try.
-
-